/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.una.informatica.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author MARTINCHO
 */
@Entity
@Table(name = "reglas")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Reglas.findAll", query = "SELECT r FROM Reglas r"),
    @NamedQuery(name = "Reglas.findByIdRegla", query = "SELECT r FROM Reglas r WHERE r.idRegla = :idRegla"),
    @NamedQuery(name = "Reglas.findByValor", query = "SELECT r FROM Reglas r WHERE r.valor = :valor"),
    @NamedQuery(name = "Reglas.findByEstado", query = "SELECT r FROM Reglas r WHERE r.estado = :estado")})
public class Reglas implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_regla")
    private Long idRegla;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "valor")
    private String valor;
    @Basic(optional = false)
    @NotNull
    @Column(name = "estado")
    private boolean estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idRegla")
    private Collection<Historial> historialCollection;
    @JoinColumn(name = "id_signo_comparacion", referencedColumnName = "id_signo_comparacion")
    @ManyToOne(optional = false)
    private SignosComparacion idSignoComparacion;
    @JoinColumn(name = "id_paciente_diagnostico", referencedColumnName = "id_paciente_diagnostico")
    @ManyToOne(optional = false)
    private DiagnosticoPaciente idPacienteDiagnostico;

    public Reglas() {
    }

    public Reglas(Long idRegla) {
        this.idRegla = idRegla;
    }

    public Reglas(Long idRegla, String valor, boolean estado) {
        this.idRegla = idRegla;
        this.valor = valor;
        this.estado = estado;
    }

    public Long getIdRegla() {
        return idRegla;
    }

    public void setIdRegla(Long idRegla) {
        this.idRegla = idRegla;
    }

    public String getValor() {
        return valor;
    }

    public void setValor(String valor) {
        this.valor = valor;
    }

    public boolean getEstado() {
        return estado;
    }

    public void setEstado(boolean estado) {
        this.estado = estado;
    }

    @XmlTransient
    public Collection<Historial> getHistorialCollection() {
        return historialCollection;
    }

    public void setHistorialCollection(Collection<Historial> historialCollection) {
        this.historialCollection = historialCollection;
    }

    public SignosComparacion getIdSignoComparacion() {
        return idSignoComparacion;
    }

    public void setIdSignoComparacion(SignosComparacion idSignoComparacion) {
        this.idSignoComparacion = idSignoComparacion;
    }

    public DiagnosticoPaciente getIdPacienteDiagnostico() {
        return idPacienteDiagnostico;
    }

    public void setIdPacienteDiagnostico(DiagnosticoPaciente idPacienteDiagnostico) {
        this.idPacienteDiagnostico = idPacienteDiagnostico;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRegla != null ? idRegla.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reglas)) {
            return false;
        }
        Reglas other = (Reglas) object;
        if ((this.idRegla == null && other.idRegla != null) || (this.idRegla != null && !this.idRegla.equals(other.idRegla))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.informatica.entidades.Reglas[ idRegla=" + idRegla + " ]";
    }
    
}
